home *** CD-ROM | disk | FTP | other *** search
/ Your Web Site Creator / Your Web Site Creator.iso / WebSite / data1.cab / Program_Executable_Files / Classes / RAINBOW2.CLA (.txt) < prev    next >
Encoding:
Java Class File  |  1999-01-13  |  2.4 KB  |  68 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.image.ImageObserver;
  7. import java.util.Random;
  8.  
  9. public class RainbowBorderPanel2 extends DynamicBorderPanel2 {
  10.    Random randomizer;
  11.    Color[] theColors;
  12.    int index;
  13.    Image osImage;
  14.    Graphics osg;
  15.  
  16.    void GetParameters(Applet var1, int var2) {
  17.       String var3 = var1.getParameter("rainbowBorderThickness" + var2);
  18.       ((BorderPanel2)this).SetThickness(AppletParam2.GetInt(var3, 5));
  19.       var3 = var1.getParameter("rainbowBorderBkColor" + var2);
  20.       ((BorderPanel2)this).SetBackgroundColor(AppletParam2.GetColor(var3, (Color)null));
  21.       var3 = var1.getParameter("rainbowBorderBkImage" + var2);
  22.       ((BorderPanel2)this).SetBackgroundImage(AppletParam2.GetImage(var1, var3));
  23.    }
  24.  
  25.    public RainbowBorderPanel2(Applet var1, int var2) {
  26.       this.GetParameters(var1, var2);
  27.       this.randomizer = new Random();
  28.       this.theColors = new Color[16];
  29.       this.theColors[0] = new Color(0, 0, 0);
  30.       this.theColors[1] = new Color(128, 0, 0);
  31.       this.theColors[2] = new Color(0, 128, 0);
  32.       this.theColors[3] = new Color(128, 128, 0);
  33.       this.theColors[4] = new Color(0, 0, 128);
  34.       this.theColors[5] = new Color(128, 0, 128);
  35.       this.theColors[6] = new Color(0, 128, 128);
  36.       this.theColors[7] = new Color(128, 128, 128);
  37.       this.theColors[8] = new Color(192, 192, 192);
  38.       this.theColors[9] = new Color(255, 0, 0);
  39.       this.theColors[10] = new Color(0, 255, 0);
  40.       this.theColors[11] = new Color(255, 255, 0);
  41.       this.theColors[12] = new Color(0, 0, 255);
  42.       this.theColors[13] = new Color(255, 0, 255);
  43.       this.theColors[14] = new Color(0, 255, 255);
  44.       this.theColors[15] = new Color(255, 255, 255);
  45.    }
  46.  
  47.    void DoPaint(Graphics var1) {
  48.       if (this.osImage == null) {
  49.          this.osImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  50.          this.osg = this.osImage.getGraphics();
  51.       }
  52.  
  53.       this.index = Math.abs(this.randomizer.nextInt()) % 16;
  54.       this.osg.setColor(this.theColors[this.index]);
  55.  
  56.       for(int var2 = 0; var2 < super.thickness; ++var2) {
  57.          this.osg.drawRect(var2, var2, ((Component)this).size().width - var2 * 2, ((Component)this).size().height - var2 * 2);
  58.       }
  59.  
  60.       var1.drawImage(this.osImage, 0, 0, (ImageObserver)null);
  61.    }
  62.  
  63.    void DoResize(int var1, int var2) {
  64.       this.osImage = null;
  65.       this.osg = null;
  66.    }
  67. }
  68.